package com.designpatterns.builder;

public class Person {
	private int idNumber;
	private String firstName;
	private String lastName;
	private int age;
	private String location;
	private String job;
	
	// Martital status.
	enum MaritalStatus {SINGLE, MARRIED};
	private MaritalStatus maritalStatus;
	
	// Sex.
	enum Sex {MALE, FEMALE};
	private Sex sex;
	
	private Person(Builder builder) {
		this.idNumber = builder.idNumber;
		this.firstName = builder.firstName;
		this.lastName = builder.lastName;
		this.age = builder.age;
		this.location = builder.location;
		this.job = builder.job;
		this.maritalStatus = builder.maritalStatus;
		this.sex = builder.sex;
	}
	
	public static class Builder {
		// Required.
		final private int idNumber;
		
		// Optional.
		private String firstName;
		private String lastName;
		private int age;
		private String location;
		private String job;
		private MaritalStatus maritalStatus;
		private Sex sex;
		
		public Builder(int idNumber) {
			this.idNumber = idNumber;
		}
		
		public Builder firstName(String firstName) {
			this.firstName = firstName;
			return this;
		}
		
		public Builder lastName(String lastName) {
			this.lastName = lastName;
			return this;
		}
		
		public Builder age(int age) {
			this.age = age;
			return this;
		}
		
		public Builder location(String location) {
			this.location = location;
			return this;
		}
		
		public Builder job(String job) {
			this.job = job;
			return this;
		}
		
		public Builder maritalStatus(MaritalStatus maritalStatus) {
			this.maritalStatus = maritalStatus;
			return this;
		}
		
		public Builder sex(Sex sex) {
			this.sex = sex;
			return this;
		}
		
		public Person build() {
			return new Person(this);
		}
	}

	public int getIdNumber() {
		return idNumber;
	}

	public String getFirstName() {
		return firstName;
	}

	public String getLastName() {
		return lastName;
	}

	public int getAge() {
		return age;
	}

	public String getLocation() {
		return location;
	}

	public String getJob() {
		return job;
	}

	public MaritalStatus getMaritalStatus() {
		return maritalStatus;
	}

	public Sex getSex() {
		return sex;
	}
}
